package com.learnyou.server.xingzuo.common.util;

public class CodeUtil {


    public static String getCode(String prefix, Integer id){
        StringBuilder batchNo = new StringBuilder();
        batchNo.append(prefix);
        return fillUp(batchNo, id).toString();
    }

    public static StringBuilder fillUp(StringBuilder batchNo, Integer id){
        String idStr = String.valueOf(id);
        int idLength = idStr.length();
        if(idLength > 6){
            idStr = idStr.substring(idLength - 6, idLength);
        }else if(idLength < 6){
            for(int i = 0; i < 6 - idLength; i++){
                batchNo.append("0");
            }
        }
        batchNo.append(idStr);
        return batchNo;
    }





}
